﻿@model warn_info
<script src="@Url.Content("~/Scripts/xheditor/xheditor-1.1.14-zh-cn.min.js")" type="text/javascript"   charset="utf-8" ></script>
<script src="@Url.Content("~/Scripts/user/egg/egg.js")" type="text/javascript"   charset="utf-8" ></script>
<link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/user/egg/egg.css")' />
@using (Html.BeginForm("Edit", "Warning", Html.ViewContext.RouteData.Values, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(a=>a.id)
    <div id="edit-car" style="width:900px;margin:5px 5px 5px 5px">

        <table class="edit-table">
            <tr>
                <td style="width: 120px; text-align: right;">*主标题：</td>
                <td>@Html.TextAreaFor(a => a.title,3,30,new { @style = "width: 100%;",@class="xheditor-simple"  })</td>
            </tr>
            <tr>
                <td style="width: 120px; text-align: right;">*图标：</td>
                <td>
                    <select id="warn_icon" name="warn_icon" class="egg_imagedropdown" size="8">
                        
                        @{
                            foreach (string item in ViewBag.AllIcons)
                            {
                                string url = @Url.Content("~/Content/warn/" + item);
                                //string isselect = Model.icon_url.IsNull("wenxingtishi.jpg") == item?"selected":"";
                                <option value="@item" data-image='@url'>@url</option>
                            }
                        }
                    </select>
                </td>
            </tr>
            
            <tr>
                <td style="width: 120px; text-align: right;">*是否浮动：</td>
                <td>@Html.CheckBoxFor(a => a.is_float,new { @style = "width: 100%;" })</td>
            </tr>
            <tr>
                <td style="width: 120px; text-align: right;">*简要说明：</td>
                <td>@Html.TextAreaFor(a => a.short_content,3,30,new { @style = "width: 100%;" })</td>
            </tr>
            
            <tr>
                <td style="width: 120px; text-align: right">*开始日期：</td>
                <td>@Html.CalendarFor(a=>a.beg_time)</td>
            </tr>
            <tr>
                <td style="width: 120px; text-align: right">*结束日期：</td>
                <td>@Html.CalendarFor(a=>a.end_time)</td>
            </tr>
            <tr>
                <td style="width: 120px; text-align: right">*附件：</td>
                <td><input type="file" name="fileImage" id="fileImage" style="width:100%" /></td>
            </tr>
            <tr>
                <td style="width: 120px; text-align: right;">*详细内容：</td>
                <td colspan="3">@Html.TextAreaFor(a => a.warn_content,15,30,new { @style = "width: 100%;",@class="xheditor-simple"  })</td>
            </tr>

        </table>
        <br />
        <div class="validation-errors">@ViewBag.ErrorMessage</div>
    </div>
    <table style="width:900px">
        <tr>
            <td style="width:850px"></td>
            <td>
                @Html.DevExpress().Button(settings =>
                {
                    settings.Name = "Button1";
                    settings.Text = "保存";
                    //settings.Enabled = CurrentUser.CheckPermission(PermissionManager.填写GPS统计表);
                    settings.UseSubmitBehavior = false;
                    settings.Width = 70;
                    settings.ControlStyle.CssClass = "button1";
                    settings.ClientSideEvents.Click = "function(s, e){ commit_data();}";
                }).GetHtml()

            </td>
            <td>
                @Html.DevExpress().Button(settings =>
                {
                    settings.ControlStyle.CssClass = "button2";
                    settings.Name = "Button2";
                    settings.Text = "取消";
                    settings.Width = 70;
                    settings.ClientSideEvents.Click = "function(s, e){ location.href='" + @Url.Action("List", "Warning") + "' }";
                }).GetHtml()
            </td>
        </tr>

    </table>
    
    <script type="text/javascript">
        $(function () {
            $('#warn_content').xheditor({ tools: 'simple' });
            $("#warn_icon").val('@Model.icon_url.IsNull("wenxingtishi.jpg")');
            //$("#warn_icon").msDropdown({ visibleRows: 6 });
            $('#warn_icon').EggImageDropdown({width:200,height:80,dropdownHeight:500});

        });
        function commit_data() {
            var t=$("#title").val();
            if (t == null || t == "") {
                alert("请输入标题。");
                return;
            }
            //if (t.indexOf("'") >= 0 || t.indexOf("\"") >= 0) {
            //    alert("标题不能带有引号。");
            //    return;
            //}
            if ($("#short_content").val() == null || $("#short_content").val() == "") {
                alert("请输入简要说明。");
                return;
            }
            if ($("#warn_content").val() == null || $("#warn_content").val() == "") {
                alert("请输入内容。");
                return;
            }
            if ($("#beg_time").val() == null || $("#beg_time").val() == "") {
                alert("请输入开始日期。");
                return;
            }
            if ($("#end_time").val() == null || $("#end_time").val() == "") {
                alert("请输入结束日期。");
                return;
            }

            var allow_ext = "rar|zip|doc|xls|";

            if (!check_file("fileImage", allow_ext, 2048)) return;

            
            document.forms[0].submit();
        };
    </script>
}